using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class cityMap : EntityTypeConfiguration<city>
    {
        public cityMap()
        {
            // Primary Key
            this.HasKey(t => new { t.citycode, t.cityname });

            // Properties
            this.Property(t => t.citycode)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(3);

            this.Property(t => t.cityname)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("cities");
            this.Property(t => t.citycode).HasColumnName("citycode");
            this.Property(t => t.cityname).HasColumnName("cityname");
        }
    }
}
